#ifndef __YHM_CLIENT_NET_H__
#define __YHM_CLIENT_NET_H__

#include <infiniband/verbs.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <queue>
#include <mutex>
#include "../shared.h"

#define CQ_DEPTH 128
#define MAX_SGE_SIZE 4
#define PSN 101

#define MR_PERMISSION                                                  \
  (IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_READ | \
   IBV_ACCESS_REMOTE_ATOMIC)
#define PP_BUCKET_NUM 1024
#define POLL_NUM 16

struct recv_ring32{
  struct m32 *mem;
  int num;
  int head, tail;
  unsigned lkey;
  struct ibv_mr *mr;
};
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
void client_conn_init(struct client_shared_ctx *ctx);
void pingpong(struct client_thread_ctx *ctx, int server_id, union req_union *req, union res_union *res);
void *poll_routine(void *p);

#endif